package com.vtc.session8;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

import com.vtc.R;

public class ActinBarActvity extends Activity{

	private Spinner spinSearch;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		ActionBar actionBar = getActionBar();
		
		actionBar.setCustomView(R.layout.menu_custom);
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
		String[] objects = {"All","Online","Favorites","Blocked"};
		ArrayAdapter<String> arrAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, objects);  
		spinSearch =(Spinner) actionBar.getCustomView().findViewById(R.id.spinSearch);
		spinSearch.setAdapter(arrAdapter);
		
		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
	    MenuInflater inflat = getMenuInflater();
	    inflat.inflate(R.menu.actiontview2_menu, menu);
	    return super.onCreateOptionsMenu(menu);
	}
	public boolean onOptionsItemSelected(MenuItem item) {
		  switch (item.getItemId()) {
		        case R.id.selecta:
		         item.setChecked(true);
		         Toast.makeText(getApplicationContext(), 
		           "A Selected", 
		           Toast.LENGTH_LONG).show();
		         return true;
		        case R.id.selectb:
		         item.setChecked(true);
		         Toast.makeText(getApplicationContext(), 
		           "B Selected", 
		           Toast.LENGTH_LONG).show();
		         return true;
		        case R.id.selectc:
		         item.setChecked(true);
		         Toast.makeText(getApplicationContext(), 
		           "C Selected", 
		           Toast.LENGTH_LONG).show();
		         return true;
		        default:
		            return super.onOptionsItemSelected(item);    
		  }
		 }
}
